#eliminate_useless_ns2.py: remove useless lines in ns2 routing file.
#Currently, we remove:
#  1. lines containing "god_" and "set-dist" at the same time.
#  2. lines starting with "#"
#Author:ktchuang
import sys
import re
if len(sys.argv) <= 2:
    print('Usage: python {0} LongInputFile EliminateOutputFile '.format(sys.argv[0]))
    raise SystemExit

print('Transfer ' + sys.argv[1] + ' to '+ sys.argv[2])
inf = open(sys.argv[1])

outf = open(sys.argv[2],'w')
lines = inf.readlines()
for line in lines:    
    match = re.search(r'god_(.)*set-dist',line)    
    if not match:        
        match1 = re.search(r'^#',line)
        if not match1:
            outf.write(line);        
inf.close();
outf.close();
